<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//  
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License

/**
 * VictoryCMS - PermissionQuery 
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @filesource
 * @package QuerySets
 */

/**
 * @package QuerySets
 * 
 * @todo Documentation
 */
class PermissionQuery extends SqlSet {
	
	/**
	 * @see trunk/include/database_abstraction_layer/SqlSet#initQuerySet()
	 */
	protected function initQuerySet() {
		$settings = VcmsSettings::getInstance();
		$prefix = $settings->getDbPrefix();
		
		// Postgres DB Queries
		if ($settings->getDbType() == 'pgsql') {
			
			// Create table
			$this->set['create_table'] = 
				'CREATE TABLE '.$prefix.'_permission (
					permission_id INTEGER UNIQUE NOT NULL CHECK (permission_id > 0),
					permission_name VARCHAR(56) UNIQUE NOT NULL )';
			
			// Drop Table
			$this->set['drop_table'] = 
				'DROP TABLE '.$prefix.'_permission';
			
			// Add permission
			$this->set['add_permission'] = 
				'INSERT INTO '.$prefix.'_permission (permission_id, permission_name)
				VALUES (%d, \'%s\')';
			
			// remove permission
			$this->set['remove_permission'] = 
				'DELETE FROM '.$prefix.'_permission 
				WHERE '.$prefix.'_permission_id = %d';
			
			// Get all permissions
			$this->set['get_all_asc'] = 
				'SELECT permission_id, permission_name FROM '.$prefix.'_permission
				ORDER BY permission_id ASC';
			
			// Check if table exists
			$this->set['check_exists'] = 
				'SELECT * FROM pg_tables WHERE tablename = \''.$prefix.'_permission\'';
			
		} elseif ($settings->getDbPrefix() == "mysql") {
			
		}
	}
}
?>
